using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace OpenWaves.Pagination
{
    [ContractClass(typeof(ContractForILazyCollection<>))]
#if !SILVERLIGHT && NET_40_OR_GREATER
    public interface ILazyCollection<out T> : ICollection, IEnumerable<T>
#else
    public interface ILazyCollection<T> : ICollection, IEnumerable<T>
#endif
    {
        IEnumerable<T> GetRange(int firstItemIndex, int maxItemsCount);
    }

    [ContractClassFor(typeof(ILazyCollection<>))]
    public abstract class ContractForILazyCollection<T> : ILazyCollection<T>
    {
        public IEnumerable<T> GetRange(int firstItemIndex, int maxItemsCount)
        {
            Contract.Requires<ArgumentException>(firstItemIndex >= 0);
            Contract.Requires<ArgumentException>(maxItemsCount >= 0);

            throw new NotImplementedException();
        }

        public abstract IEnumerator<T> GetEnumerator();
        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public abstract void CopyTo(Array array, int index);
        public abstract int Count { get; }
        public abstract object SyncRoot { get; }
        public abstract bool IsSynchronized { get; }
    }
}